package cn.wolfcode.crm.web.controller;


import cn.wolfcode.crm.domain.Systemdictionary;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ISystemdictionaryService;
import cn.wolfcode.crm.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("systemDictionary")
@Controller
public class SystemdictionaryController {
    @Autowired
    private ISystemdictionaryService systemdictionaryService;

    @RequestMapping("list")
    public String list(Model model,@ModelAttribute("qo") QueryObject qo) {
        model.addAttribute("pageInfo", systemdictionaryService.queryForList(qo));
        return "systemdictionary/list";
    }

    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(Systemdictionary entity) {
        systemdictionaryService.saveOrUpdate(entity);
        return new JsonResult();
    }

    @RequestMapping("delete")
    @ResponseBody
    public Object delete(Long id) {
        if (id != null) {
            systemdictionaryService.delete(id);
        }
        return new JsonResult();
    }
}
